package io.cici.samples.processors;

import io.cici.worker.core.processor.ProcessResult;
import io.cici.worker.core.processor.TaskContext;
import io.cici.worker.core.processor.sdk.BasicProcessor;

import java.util.Optional;

/**
 * @author Echo009
 * @since 2022/4/27
 */
public class SimpleProcessor implements BasicProcessor {

    @Override
    public ProcessResult process(TaskContext context) throws Exception {


        String jobParams = Optional.ofNullable(context.getJobParams()).orElse("S");
//        logger.info("Current context:{}", context.getWorkflowContext());
//        logger.info("Current job params:{}", jobParams);

        // 测试中文问题 #581
        if (jobParams.contains("CN")) {
            return new ProcessResult(true, "任务成功啦！！！");
        }

        return jobParams.contains("F") ? new ProcessResult(false) : new ProcessResult(true, "yeah!");

    }
}